package main

import (
	"fmt"
)

//从java进制转换复制而来
func convertToBase7(num int) string {
	digits := []byte{'0', '1', '2', '3', '4', '5', '6', '7'}
	buf := make([]byte, 33)
	radix := 7
	negative := num < 0
	charPos := 32
	if !negative {
		num = -num
	}
	for num <= -radix {
		buf[charPos] = digits[-(num % radix)]
		charPos--
		num = num / radix
	}
	buf[charPos] = digits[-num]

	if negative {
		charPos--
		buf[charPos] = '-'
	}
	return string(buf[charPos:33])
}

func main() {
	fmt.Println(convertToBase7(-100))
	fmt.Println(convertToBase7(100))
	fmt.Println(convertToBase7(-7))
}
